#-----------------------------------------------------------------------;
# COMMON MAKEFILE Variables	and Commands							;
#									;
# Developed from PICTOR Makefile, Version 1.51, Copyright (c) 1992-94 SoftCircuits	;
# Redistributed by permission.						;
# Copyright (c) 2012-2013 William D. Jones
#-----------------------------------------------------------------------;

COMPILER=3	# 1 = Microsoft C 7.0, 2 = Borland C 3.0, 3 = OpenWatcom 1.9
MODEL=1		# 1 = small/tiny, 2 = medium, 3 = compact, 4 = large/huge
DEBUG=1		# 1 = Enable debug, 0 = Disable debug
#-----------------------------------------------------------------------;

HELPDIR=.\HELP
UTILDIR=.\UTILS
EDDIR=.\ED
EXAMPLEDIR=.\EXAMPLES
LIBDIR=.\LIBSRC
BINDIR=.\BIN

NMAKEFLAGS= -NOLOGO
#ROOTDIR=

!IF $(COMPILER)==1
SMALL=S
MEDIUM=M
COMPACT=C
LARGE=L
!ELSE
!IF $(COMPILER)==2
SMALL=s
MEDIUM=m
COMPACT=c
LARGE=l
!ELSE
!IF $(COMPILER)==3
SMALL=S
MEDIUM=M
COMPACT=C
LARGE=L
!ELSE
!ERROR Unknown compiler specified
!ENDIF
!ENDIF
!ENDIF

!IF $(MODEL)==1
MODELCHR=$(SMALL)
MODELSTR=small
!ELSE
!IF $(MODEL)==2
MODELCHR=$(MEDIUM)
MODELSTR=medium
!ELSE
!IF $(MODEL)==3
MODELCHR=$(COMPACT)
MODELSTR=compact
!ELSE
!IF $(MODEL)==4
MODELCHR=$(LARGE)
MODELSTR=large
!ELSE
!ERROR Unknown memory model
!ENDIF
!ENDIF
!ENDIF
!ENDIF


#All includes should be relative to the root directory.
!IF $(COMPILER)==1	# Microsoft C
LIBNAME=PICTOR$(MODELCHR)M
CC=cl
CFLAGS=/W3 /A$(MODELCHR) /Ox /c
AS=ml
AFLAGS=/Dmemmodel=$(MODELSTR) /W3 /c
LIB=lib
LIBFLAGS=
LINKER=
LFLAGS=
!ENDIF

!IF $(COMPILER)==2	# Borland C
LIBNAME=PICTOR$(MODELCHR)B
CC=bcc
CFLAGS=/m$(MODELCHR) /O1 /c
AS=tasm
AFLAGS=/Dmemmodel=$(MODELSTR) /W2 /m2 /mx
LIB=tlib
LIBFLAGS=
LINKER=
LFLAGS=
!ENDIF


!IF $(COMPILER)==3	# Watcom C
LIBNAME=PICTOR$(MODELCHR)W
CC=wcc

!IF $(DEBUG)==1
CFLAGS=-m$(MODELCHR) -i=..\$(LIBDIR) -od -d__DOS__ -dMOUSE_SUPPORT -dEXT_PICKFILE -ecw -q -d2
!ELSE
CFLAGS=-m$(MODELCHR) -i=..\$(LIBDIR) -os -d__DOS__ -dMOUSE_SUPPORT -dEXT_ED -dEXT_PICKFILE -ecw -q
!ENDIF
AS=wasm
AFLAGS=-dmemmodel=$(MODELSTR) -zq -d1
LIB=wlib
LIBFLAGS=-q
LINKER=wlink

!IF $(DEBUG)==1
LFLAGS=debug all option quiet system dos libpath ..\$(LIBDIR)
!ELSE
LFLAGS=option quiet system dos libpath ..\$(LIBDIR)
!ENDIF
!ENDIF

#!endif pending at end of file occurs in the following code in OpenWatcom's NMAKE clone.
!IFNDEF TOPLEVEL
all: $(EXES)

redo: clean all install

#Assume BIN directory exists.
install: .symbolic
	copy /Y *.EXE ..\$(BINDIR)

dbg-clean: .symbolic
	del *.obj *.lib *.exe

clean: .symbolic
	del *.obj *.lib *.err *.exe
!ENDIF